HTTP Status re-fix take 2

James Peret 8 年之前
父节点
当前提交
807bbec724
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2 4
      app/models/agents/http_status_agent.rb

+ 2 - 4
app/models/agents/http_status_agent.rb

@@ -83,7 +83,7 @@ module Agents
83 83
       payload = { 'url' => url, 'response_received' => false, 'elapsed_time' => total_time }
84 84
 
85 85
       # Deal with failures
86
-      if measured_result
86
+      if measured_result.status != 0
87 87
         final_url = boolify(options['disable_redirect_follow']) ? url : measured_result.to_hash[:url]
88 88
         payload.merge!({ 'final_url' => final_url, 'redirected' => (url != final_url), 'response_received' => true, 'status' => current_status })
89 89
         # Deal with headers
@@ -104,9 +104,7 @@ module Agents
104 104
 
105 105
     def ping(url)
106 106
       result = faraday.get url
107
-      if result.status != 0
108
-        return result
109
-      end
107
+      result.status != 0 ? result : nil
110 108
     rescue
111 109
       nil
112 110
     end